<script setup lang="ts">

import { ChatDotRound, InfoFilled, Message, Search, Unlock } from '@element-plus/icons-vue'
import { localCache } from '@/util/cache.ts'

const userinfo = localCache.getCache('userinfo')
</script>

<template>
  <div class="personal-info">
    <div class="operation">
      <span>
        <el-icon><Message/></el-icon>
      </span>

      <span>
        <span class="dot"></span>
        <el-icon><ChatDotRound/></el-icon>
      </span>
      <span>
        <el-icon><Search/></el-icon>
      </span>
    </div>
    <!-- 个人信息   -->
    <div class="info">

      <el-dropdown :hide-on-click="false">
        <span class="user-info">
        <el-avatar :size="40" class="avatar" src="https://iknow-pic.cdn.bcebos.com/6609c93d70cf3bc7c8adaf73c300baa1cc112afb" />
        <span class="username">{{ userinfo.realname }}</span>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>
              <el-icon><InfoFilled/></el-icon>
              <span>个人信息</span>
            </el-dropdown-item>
            <el-dropdown-item divided>
              <el-icon><Unlock/></el-icon>
              <span>修改密码</span>
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>

    </div>
  </div>
</template>

<style scoped>
.personal-info {
  display: flex;
  align-items: center;
}

.operation {
  display: inline-flex;
  margin-right: 20px;
  span {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 35px;

    &:hover {
      background: #f2f2f2;
    }
    i {
      font-size: 20px;
    }
    .dot {
      position: absolute;
      top: 3px;
      right: 3px;
      z-index: 10;
      width: 6px;
      height: 6px;
      background: red;
      border-radius: 100%;
    }
  }
}

.info {
  .user-info{
    display: flex;
    align-items: center;
    .username{
      margin-left: 5px;
    }
  }
}

.info{
  :global(.el-dropdown-menu__item){
    line-height: 36px !important;
    padding: 6px 22px;
  }
}
</style>
